package com.zyz.K_集合.collection接口;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:
 * @version: 1.0
 */
public class TestCollection {
    public static void main(String[] args) {
        //ArrayList 是 Collection的子接口 List的实现类之一
        Collection collection = new ArrayList();
        collection.add(111);
        collection.add(222);
        collection.add("vick");
        collection.add(new String("aaaa"));
        //集合转数组
        Object[] array = collection.toArray();
        System.out.println("数组返回collection中的所有元素：" + Arrays.toString(array));

        //数组转集合
        Object[] obj = {123, "AA", "vick"};
        Collection list = Arrays.asList(obj);
        System.out.println(list);
    }
}
